<template>
    <el-form :model="cBuildingForm" status-icon :rules="rules" ref="cBuildingForm"
             label-width="150px"
             style="margin-top: 10px;color: #1f2d3d">
        <el-form-item class="form-label" label="建筑编号" prop="bid">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.bid" placeholder="建筑编号"
                          maxlength="11" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="目标名称" prop="objectName">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.objectName" placeholder="目标名称"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="地理位置" prop="location">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.location" placeholder="地理位置"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="经度" prop="lon">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.lon" placeholder="经度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="纬度" prop="lat">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.lat" placeholder="纬度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="结构类型" prop="structType">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.structType" placeholder="结构类型"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="建筑面积" prop="structArea">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.structArea" placeholder="建筑面积"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="建筑年代" prop="year">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.year" placeholder="建筑年代"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="层数" prop="storyNumber">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.storyNumber" placeholder="层数"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="总高度" prop="strutHeight">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.strutHeight" placeholder="总高度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="首层高度" prop="firstHeight">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.firstHeight" placeholder="首层高度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="设防标准" prop="intensity">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.intensity" placeholder="设防标准"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="场地类型" prop="fieldType">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.fieldType" placeholder="场地类型"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="平立面规则度" prop="planeRegularization">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.planeRegularization" placeholder="平立面规则度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="基础形式" prop="foundationType">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.foundationType" placeholder="基础形式"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="用途" prop="useful">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.useful" placeholder="用途"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="柱子混凝土强度" prop="columConcreteStrength">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.columConcreteStrength" placeholder="柱子混凝土强度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="砂浆强度" prop="mortarStrength">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.mortarStrength" placeholder="砂浆强度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="砖强度" prop="brickStrength">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.brickStrength" placeholder="砖强度"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="现状评价" prop="status">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.status" placeholder="现状评价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="重建单位面积造价" prop="reconstructionCost">
            <el-col :span="19">
                <el-input v-model="cBuildingForm.reconstructionCost" placeholder="重建单位面积造价"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="关联子任务" prop="sid" style="display: none">
            <el-input v-model="cBuildingForm.sid"
                      maxlength="20" autocomplete="off"/>
        </el-form-item>
    </el-form>
</template>

<script>
    import qs from 'qs';

    export default {
        name: "NewCorrespondBuilding",
        data() {
            return {
                cBuildingForm: {
                    id: '',
                    bid: '',
                    objectName: '',
                    location: '',
                    lon: '',
                    lat: '',
                    structType: '',
                    structArea: '',
                    year: '',
                    storyNumber: '',
                    strutHeight: '',
                    firstHeight: '',
                    intensity: '',
                    fieldType: '',
                    planeRegularization: '',
                    foundationType: '',
                    useful: '',
                    columConcreteStrength: '',
                    mortarStrength: '',
                    brickStrength: '',
                    status: '',
                    reconstructionCost: '',
                    sid: ''
                },
                rules: {
                    bid: [],
                    objectName: [],
                    location: [],
                    lon: [],
                    lat: [],
                    structType: [],
                    structArea: [],
                    year: [],
                    storyNumber: [],
                    strutHeight: [],
                    firstHeight: [],
                    intensity: [],
                    fieldType: [],
                    planeRegularization: [],
                    foundationType: [],
                    useful: [],
                    columConcreteStrength: [],
                    mortarStrength: [],
                    brickStrength: [],
                    status: [],
                    reconstructionCost: []
                }
            }
        },
        mounted() {
            if (this.id !== -1) {
                axios.post("/bjdzms/correspondImportBuilding/findById",
                    qs.stringify({
                        'id': this.id
                    })).then(res => {
                    this.cBuildingForm = res.data.datas;
                });
            }
        },
        props: {
            sid: {
                type: Number,
                default: -1
            },
            id: {
                type: Number,
                default: -1
            }
        },
        methods: {
            to(path) {
                this.$router.push({name: path});
            },
            submitForm() {
                if (this.id !== -1) {
                    this.cBuildingForm.id = this.id;
                    axios.post("/bjdzms/correspondImportBuilding/upd",
                        qs.stringify(this.cBuildingForm)
                    ).then(res => {
                        this.$emit('updateData');
                    });
                } else {
                    this.cBuildingForm.sid = this.sid;
                    axios.post("/bjdzms/correspondImportBuilding/add",
                        qs.stringify(this.cBuildingForm)
                    ).then(res => {
                        this.$emit('updateData');
                    });
                }
            }
        }
    }
</script>

<style>
    .el-upload-dragger {
        height: 40px !important;
    }
</style>

<style scoped>
    .el-header {
        background: #EBEBEB;
        color: #e5e9ef;
        font-size: 2em;
        line-height: 80px;
        border: 5px solid #EBEBEB;
    }

    .el-main {
        background: #fff;
    }

    .el-container {
        height: 100%;
    }

    .el-form-item {
        width: 610px;
    }
</style>

